#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
int main()
{
    int n, m;
    scanf("%d %d", &n, &m);
    int a[200];
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
    m = m % n;
    for (int i = n - 1; i >= 0; i--)
    {
        a[i + m] = a[i];
    }
    for (int j = 0; j < m; j++)
    {
        a[j] = a[j + n];
    }
    for (int t = 0; t < n; t++)
    {
        if (t == 0)
        {
            printf("%d", a[t]);
        }
        else
        {
            printf(" %d", a[t]);
        }
    }
    return 0;
}